package com.gs.weather.controller;

import com.gs.weather.entity.DisasterForecast;
import com.gs.weather.service.DisasterForecastService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "forecast")
public class DisasterForecastController {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    DisasterForecastService service;

    /*
    查询所有灾情预测信息
     */
    @RequestMapping(value = "queryAll")
    @ResponseBody
    public List<DisasterForecast> queryAll() {
        return service.queryAll();
    }

    /*
    更新灾情预测信息
     */
    @RequestMapping(value = "update")
    @ResponseBody
    public ResponseEntity updateDisasterForecast(DisasterForecast disasterForecast) {
        logger.info("updateDisasterForecast->{}", disasterForecast);
        return service.update(disasterForecast);
    }

    /*
    根据灾情预测名字查询阈值
     */

    @RequestMapping(value = "queryThreshold")
    @ResponseBody
    public Double queryThreshold(String name) {
        logger.info("queryThreshold->{}", name);
        return service.queryThreshold(name);
    }
    /*
    添加灾情预测信息
     *//*
    @RequestMapping(value = "add")
    public ResponseEntity addDisasterForecast(@RequestBody DisasterForecast disasterForecast) {
        service.add(disasterForecast);
        logger.info("addDisasterForecast->{}", disasterForecast);
        return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
    }

    /*
    删除灾情预测信息
     *//*
    @RequestMapping(value = "delete")
    @ResponseBody
    public ResponseEntity deleteDisasterForecast(int id) {
        logger.info("deleteDisasterForecast->{}", id);
        return service.delete(id);
    }*/
}
